/*************************************************************************
 * @file: halfedge.h
 * @date: 01/04/2012
 * TOPOL v1_0 - (c)copyright 2012 TEC/UFF
 *************************************************************************
 * This is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 ************************************************************************/

#ifndef _HALFEDGE
#define _HALFEDGE

// includes
//----------

// forward declarations
//----------------------
class Edge;
class Vertex;
class Loop;


/*!
 * CLASS
 * HalfEdge
 * 
 * This class implements the requirement for the topological entity named
 * HalfEdge and sets all the necessary adjacency informations
 * 
 * @author Andre Pereira (andremaues@id.uff.br)
 * @version 1.0.0
 * @see Edge
 * @see Vertex
 * @see Loop
 */
class HalfEdge
{

public:

  ////////////////////////////////////////////////
  ///  Constructor and Destructor Declaration  ///
  ////////////////////////////////////////////////

  /**
   * @brief Constructs a half-edge
   */
	HalfEdge();

  ////////////////////////////////////
  ///  PUBLIC Methods Declaration  ///
  ////////////////////////////////////

  /**
   * @brief Prepares the half-edge to be deleted
   * @return HalfEdge* pointer to the half-edge to be deleted
   */
  HalfEdge* delhe();

  /**
   * @brief Gets the previous half-edge
   * @return HalfEdge* pointer to the previous half-edge object
   */
  HalfEdge* getPrv();

  /**
   * @brief Gets the next half-edge
   * @return HalfEdge* pointer to the next half-edge object
   */
  HalfEdge* getNxt();

  /**
   * @brief Gets the loop associated with this half-edge
   * @return Loop* pointer to the loop associated with this half-edge
   */
	Loop* getLoop();

  /**
   * @brief Gets the edge which this half-edge belongs to 
   * @return Edge* pointer to the edge which this half-edge belongs to
   */
	Edge* getEdg();

  /**
   * @brief Gets the starting vertex of the half-edge
   * @return Vertex* pointer to the half-edge starting vertex
   */
	Vertex* getVtx();

  /**
   * @brief Gets the opposite half-edge
   * @return HalfEdge* pointer to the opposite half-edge
   */
	HalfEdge* mate();

  /**
   * @brief Sets the half-edge that is previous to the current one
   * @param _he is the previous half-edge
   */
  void setPrv( HalfEdge* _he );

  /**
   * @brief Sets the half-edge that is next to the current one
   * @param _he is the next half-edge
   */
  void setNxt( HalfEdge* _he );

  /**
   * @brief Sets the loop which this half-edge belongs to
   * @param _loop is a loop which contains the half-edge
   */
  void setWloop( Loop* _loop );

  /**
   * @brief Sets the edge which this half-edge belongs to
   * @param _edge is a edge which contains the half-edge
   */
  void setEdg( Edge* _edge );

  /**
   * @brief Sets the starting vertex of this half-edge
   * @param _vertex is the starting vertex of the half-edge
   */
  void setVtx( Vertex* _vertex );
	

private:

  ////////////////////////////////
  ///  Attributes Declaration  ///
  ////////////////////////////////

  /** @brief Pointer to the previous half-edge */
	HalfEdge* m_prv;

  /** @brief Pointer to the next half-edge */
	HalfEdge* m_nxt;

  /** @brief Pointer to the parent edge */
	Edge* m_edg;

  /** @brief Pointer to the starting vertex */
	Vertex* m_vtx;

  /** @brief Back pointer to the loop */
	Loop* m_wloop;

};

#endif
